﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using MultiTenant.SeparateSchema.Api.Data.Context;

namespace MultiTenant.SeparateSchema.Api.Data;

internal class TenantModelCacheKeyFactory : IModelCacheKeyFactory
{
	public object Create(DbContext context, bool designTime)
	{
		return context is ApplicationDbContext dbContext 
			? (typeof(ApplicationDbContext), dbContext.GetCurrentTenant().Id) 
			: context.GetType();
	}
}
